<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="root"></div>

    <script
      src="https://unpkg.com/react@18/umd/react.development.js"
      crossorigin
    ></script>
    <script
      src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
      crossorigin
    ></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

    <script type="text/babel">
      const root = ReactDOM.createRoot(document.querySelector('#root'))

      class App extends React.Component {
        constructor() {
          super()

          this.state = {}
        }

        btnClick(event, name, age) {
          console.log('event this: ', event, this)
          console.log('name age: ', name, age)
        }

        render() {
          return (
            <div>
              {/* 1.event参数传递 */}
              <button onClick={this.btnClick}>按钮1</button>
              <button onClick={(event) => this.btnClick(event)}>按钮2</button>

              {/* 2.传递其他参数 */}
              {/* bind传递的需注意参数顺序问题 */}
              <button onClick={this.btnClick.bind(this, 'hxl', 18)}>
                按钮3（不推荐）
              </button>
              <button onClick={(event) => this.btnClick(event, 'hxl', 18)}>
                按钮4
              </button>
            </div>
          )
        }
      }

      root.render(<App />)
    </script>
  </body>
</html>
